<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include($root . "/util/session.php"); //checks that the user is logged in
unset($_SESSION['questionAdd']);
unset($_SESSION['IDupd']);
unset($_SESSION['type']);
$_SESSION['questionUpdDel'] = 'true';

if(isset($_GET['IDdel']))
{
    $ID = $_GET['IDdel'];    
    $sql_delete = "DELETE FROM questions WHERE questionID = $ID";
    
    if (mysqli_query($db, $sql_delete)) {
        mysqli_close($db);               
    } else {
        echo "Error: " . $sql . "<br>" . mysqli_error($db);
    }
}
else if(isset($_GET['IDupd']) && isset($_GET['type']))
{
    $ID = $_GET['IDupd'];
    $type = $_GET['type'];
    $_SESSION['IDupd'] = "$ID";
    $_SESSION['type'] = "$type";    
}
header("location: ../teacher.php");
